<template>
    <div class="news-info">
        <div class="head">{{con.title}}</div>
        <div class="tip">
            <div class="time">{{con.add_time | timeFormat}}</div>
            <div class="click">点击：{{con.click}}次</div>
        </div>
        <hr>
        <div v-html="con.content"></div>
        <comment :id="id"></comment>
    </div>
</template>

<script>
    import axios from "axios"
    import comment from "../subcom/comment.vue"
    export default {
        name: "newsinfo",
        data(){
            return{
                id: this.$route.params.id,
                con:{}
            }
        },
        components:{
            "comment": comment
        },
        methods:{
            getnews(){
                axios.get("/api/getnew/"+this.id)
                    .then( data=>{
                        // console.log(data)
                        this.con = data.data.message[0]
                        // console.log(data.data)
                    })
                    .catch( err=>{
                        console.log("出错了")
                        // Toast("出错了")
                })
            }
        },
        created(){
            this.getnews();
        }
    }
</script>

<style scoped lang="less">
    .news-info{
        padding: 0 4px;

        .head{
            text-align: center;
            font-size: 16px;
            color: #000;
            margin: 14px 0;
        }
        .tip{
            display: flex;
            justify-content: space-between;
            color: deepskyblue;
            font-size: 12px;
        }
    }
</style>